package johnsen.id.project;

import java.awt.event.KeyEvent;

public class MenuState {
	public static final int HEIGHT = 500;
	public static final int WIDTH = 800;

	public static void menu() {
		while (true) {

			// If player hits Q, exit the game
			if (StdDraw.isKeyPressed(KeyEvent.VK_Q)) {
				System.exit(0);
			}

			// Set the screen to black
			clear();
			// Render title. This never changes
			renderTitle();
			// check if the mouse is over playgame
			PlayGameMouseCheck();

			// check if the mouse is over settings
			SettingsMouseCheck();

			//displayMouseCoords();

			// display and pause for 20 milliseconds
			StdDraw.show(15);
		}
	}

	public static void renderTitle() {
		StdDraw.picture(0, .74, "res/pong.png");
		StdDraw.picture(0, 0, "res/epicCucumber.png");
	}

	public static void renderSettingsButton(String filePath) {
		StdDraw.picture(-.6, 0, filePath);
	}

	public static void renderPlay(String filePath) {
		StdDraw.picture(.6, 0, filePath);
	}

	public static void SettingsMouseCheck() {
		if ((StdDraw.mouseX() > -0.95 && StdDraw.mouseX() < -0.261)
				&& (StdDraw.mouseY() < 0.264 && StdDraw.mouseY() > -0.25)) {
			renderSettingsButton("res/settingsLight.png");
			if (StdDraw.mousePressed()) {
				HelpState.instructions();
			}
		} else {
			renderSettingsButton("res/settingsDark.png");
		}
	}

	public static void PlayGameMouseCheck() {
		if ((StdDraw.mouseX() > 0.28 && StdDraw.mouseX() < 0.93)
				&& (StdDraw.mouseY() < 0.13 && StdDraw.mouseY() > -0.264)) {
			renderPlay("res/playGameLight.png");
			if (StdDraw.mousePressed()) {
				GameState.game();
			}
		} else {
			renderPlay("res/playGameDark.png");
		}
	}

	public static void displayMouseCoords() {
		StdDraw.setPenColor(StdDraw.WHITE);
		StdDraw.setFont();
		StdDraw.textLeft(-.5, 0, "MouseX: " + StdDraw.mouseX());
		StdDraw.textLeft(-.5, .3, "MouseY: " + StdDraw.mouseY());
	}

	public static void clear() {
		StdDraw.clear(StdDraw.BLACK);
	}
}
